import request from '@/utils/request'

const base_api = '/admin/system/sysRole'
// 分页查询角色列表
export const GetSysRoleListByPage = (current, limit, queryDto) => {
    return request({
        url: `${base_api}/findByPage/${current}/${limit}`,
        method: 'post',
        //接口@RequestBody前端data：名称 以json格式传输
        //接口里面没有@RequestBody，前端param：名称 以普通方式传递
        data: queryDto,
    })
}
//角色添加
export const SaveSysRole = (sysRole) => {
    return request({
        url: `${base_api}/saveRole`,
        method: 'post',
        data: sysRole,
    })
}

//修改角色
export const UpdateSysRole = (sysRole) => {
    return request({
        url: `${base_api}/updateSysRole`,
        method: 'put',
        data: sysRole,
    })
}
//删除角色
export const DeleteSysRole = (roleid) => {
    return request({
        url: `${base_api}/deleteById/${roleid}`,
        method: 'delete',
    })
}
//查询所有角色
export const GetAllRoleList = (userId) => {
    return request({
        url: `${base_api}/findAllRoles/${userId}`,
        method: 'get',
    })
}

// 查询指定角色所对应的菜单id
export const GetSysRoleMenuIds = (roleId) => {
    return request({
        url: "/admin/system/sysRoleMenu/findSysRoleMenuByRoleId/" + roleId,
        method: 'get'
    })
}
// 根据角色分配菜单请求方法
export const DoAssignMenuIdToSysRole = (assignMenuDto) => {
    return request({
        url: "/admin/system/sysRoleMenu/doAssign",
        method: 'post',
        data: assignMenuDto
    })
}